//
//  SearchTerndyCell.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/6.
//

import UIKit

class SearchTerndyCell: UITableViewCell {
    
    lazy var terndyLabel: UILabel = {
        let label = UILabel()
        label.textColor = .black
        label.textAlignment = .center
        label.font = .wn_font(name: .bold, size: 14)
        return label
    }()
    
    var model: String? {
        didSet {
            if let m = model {
                terndyLabel.text = m
                let w = wn_getTextW(textStr: m, font: .wn_font(name: .bold, size: 14), height: 34)
                terndyLabel.snp.updateConstraints { make in
                    make.width.equalTo(w+24)
                }
                terndyLabel.wn_cornerWithBorder(17, 0.5, .init(named: "gray_999999")!)
                layoutIfNeeded()
            }
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.addSubview(terndyLabel)
        terndyLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(12)
            make.height.equalTo(34)
            make.width.equalTo(0)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
